﻿using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.OpenApi.Models;
using System;
using System.Collections.Generic; 

namespace System.Extensions
{
    //public static class SwaggerExtensions
    //{
    //    public static IApplicationBuilder UseSwaggerExtension(this IApplicationBuilder builder, IConfiguration config)
    //    {
    //        string swaggerName = config.GetValue<string>("Swagger:Name");
    //        string swaggerVersion = config.GetValue<string>("Swagger:Version");

    //        builder.UseSwagger(c =>
    //        {
    //            c.RouteTemplate = $"{swaggerName}/{{documentName}}/swagger.json";
    //            c.PreSerializeFilters.Add((swagger, httpReq) =>
    //            {
    //                swagger.Servers = new List<OpenApiServer> {
    //                    new OpenApiServer { Url = $"{httpReq.Scheme}://{httpReq.Host.Value}", Description="本地环境" }
    //                };
    //            });
    //        });

    //        builder.UseSwaggerUI(c =>
    //        {
    //            c.SwaggerEndpoint($"/{swaggerName}/{swaggerVersion}/swagger.json", swaggerName);

    //            c.ShowExtensions();
    //            c.RoutePrefix = string.Empty;
    //            c.DocumentTitle = swaggerName;
    //        });
    //        return builder;
    //    } 
    //}
}
